﻿using System.Threading;
using Hopscotch.Common.Contracts.AppService;
using Hopscotch.Domain.Common;
using Hopscotch.Domain.Common.StateTracking;

namespace Hopscotch.Server.AppServiceFake
{
	public abstract class FakeServiceBase<T, TKey> : IDomainService<T, TKey>
		where T : DomainBase<TKey>
		where TKey : struct
	{

		protected virtual string EntityType
		{
			get
			{
				return typeof(T).Name;
			}
		}

		protected void FakeDelay(int delay = 2000)
		{
			//Simulate some latency
			Thread.Sleep(delay);
		}

		public string Ping()
		{
			return string.Format("Hello\n{0}", this.GetType().Name);
		}

		public abstract T Get(TKey id);
		public abstract T Save(T entity);
		public abstract void Delete(T entity);
	}
}
